export const productMutations = {
    ALL_PRODUCTS(state) {
        state.showLoader = true
    },
    ALL_PRODUCTS_SUCCESS(state, payload) {
        const { products } = payload

        state.showLoader = false
        state.products = products
    },
    PRODUCT_BY_ID(state) {
        state.showLoader = true
    },
    PRODUCT_BY_ID_SUCCESS(state, payload) {
        state.showLoader = false
        const { product } = payload
        state.product = product
    }
}

export const cartMutations = {
    ADD_TO_CART(state, payload) {
        const { product } = payload
        state.cart.push(product)
    },
    REMOVE_FROM_CART(state, payload) {
        const { productId } = payload
        state.cart = state.cart.filter(product => product._id !== productId)
    }
}
